package com.example.esp8266.Library.RoomLib.Dao_Interface;

import androidx.room.Dao;
import androidx.room.Delete;
import androidx.room.Insert;
import androidx.room.OnConflictStrategy;
import androidx.room.Query;
import androidx.room.Update;

import com.example.esp8266.Library.RoomLib.Task;
import com.example.esp8266.Library.RoomLib.TaskDetail;

import java.util.List;

@Dao
public interface TaskDao {
    @Insert
    long insert(Task task);

    @Update
    void update(Task task);

    @Delete
    void delete(Task task);

    @Query("SELECT * FROM task WHERE taskGroupId = :taskGroupId")
    List<Task> getTasksByGroupId(int taskGroupId);

    @Query("DELETE FROM task")
    void deleteAll();  // 删除所有记录的方法

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    void insertTask(TaskDetail taskDetail);
}